package q2;

import java.util.ArrayList;
import java.util.Stack;

public class Solution {
    public int reverse(int x) {
        boolean isNeg = false;
        if (x < 0) {
            x = 0 - x;
            isNeg = true;
        }
        Stack<Integer> stack = new Stack<>();
        while (x != 0) {
            stack.push(x % 10);
            x /= 10;
        }
        int size = stack.size();
        for (int i = 0 ; i < size ; i++) {
            x += Math.pow(10,i) * stack.pop();
        }
        return isNeg?-1*x : x;
    }

    public static void main(String[] args) {
        System.out.println((new Solution()).reverse(-10034));;
    }
}